<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 过滤器是文本格式化 -->
      <h2>过滤器</h2>
      <!-- <p>性别: {{ sex === 1 ? '男' : "女" }}</p> -->
      <p>性别: {{ sex | fn }}</p>
      <!-- <img :src="img | fn2" alt="" /> -->
      <p>{{ time | fn3 }}</p>
      <img v-for="item in imgs" :src="fn4(item)" alt="" />
    </div>

    <script src="./Vue2.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          sex: 1,
          imgs: [
            "http://p1.meituan.net/w.h/movie/13cb85d810b0530b951625430c2f35044951112.jpg",
            "http://p1.meituan.net/w.h/movie/13cb85d810b0530b951625430c2f35044951112.jpg",
            "http://p1.meituan.net/w.h/movie/13cb85d810b0530b951625430c2f35044951112.jpg",
            "http://p1.meituan.net/w.h/movie/13cb85d810b0530b951625430c2f35044951112.jpg",
            "http://p1.meituan.net/w.h/movie/13cb85d810b0530b951625430c2f35044951112.jpg",
          ],
          time: 1666231002641,
        },
        filters: {
          fn(val) {
            return val === 1 ? "男" : "女";
          },
          fn2(val) {
            return val.split("/w.h").join("");
          },
          fn3(val) {
            // .....
            return "22年...";
          },
        },
      });
    </script>
  </body>
</html>
